// 这里用来统一ajax请求的

// 1.先引入封装好的ajax
import ajax from './ajax'
import mockAjax from './mockaxios'
// 2.定义一个对象并导出

// 发送获取三级导航数据并导出
export const reqgetBaseCategoryList = () => {
  return ajax.get('/product/getBaseCategoryList')
}

//轮播图数据
export const mockAjaxList = () => {
  return mockAjax.get('/banner')
}

//楼层数据
export const mockAjaxFloor = () => {
  return mockAjax.get('/floor')
}


//发送搜索商品请求

export const search_commodity = (searcHParams) => {
  return ajax.post(`/list`,searcHParams)
}

//获取商品详情数据

export const reqGoodDetailInfoData = (id) => {
  return ajax.get('/item/'+id)
}

//添加购物车成功数据

export const reqaddCartSuccessData = (skuId,skuNum) => {
  // 商品的id和商品名
  return ajax.post(`/cart/addToCart/${skuId}/${skuNum}`)
}

//获取购物车数据
export const reqShopCartListData = () => {

  return ajax.get(`/cart/cartList/`)
}

// 9.更新购物车结算中数据选中的状态
export const reqcheckCartliststate = (skuId,isChecked) => {
  return ajax.get(`/cart/checkCart/${skuId}/${isChecked}`)
}

//批量更新购物车中商品的选中状态

export const reqChangeAllCartState = (isChecked, skuIdlist) =>
ajax({
  url: `/cart/batchCheckCart/${isChecked}`,
  method: 'post',
  data: skuIdlist
})

//删除购物车商品
export const reqdeldeleteCart = (skuId) => {
   return ajax.delete(`/cart/deleteCart/${skuId}`)
}
//批量删除商品
export const reqdeldeleteCartbatch = (selectedObj) => {
  return ajax.delete(`/cart/batchDeleteCart`,{data:selectedObj})
}

//更改购物车商品数量

export const reqaddToCartlistd= (skuId,skuNum) => {
  return ajax.post(`/cart/addToCart/${ skuId }/${ skuNum }`)
}

//  获取验证码
export const reqGetVerifyCode = phone => ajax.get(`/user/passport/sendCode/${phone}`)

// 实现注册
export const reqUserRegister = user => ajax.post('/user/passport/register', user)

//登陆请求接口

export const reqUserLogin = (user) => ajax.post('/user/passport/login', user)

//登出

export const reqUserLoginx = () => ajax.get('/user/passport/logout')

//获取邮寄地址的接口

//获取订单交易信息
export const reqTradeInfoData = () => ajax.get('/order/auth/trade')